package com.truyen.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.truyen.persistence.dao.ContentTruyenTrollDao;
import com.truyen.persistence.entity.TruyenTroll;
import com.truyen.persistence.entity.ContentTruyenTroll;
import com.truyen.service.ContentTruyenTrollService;
import com.truyen.utils.PagingInfo;


@Service
public class ContentTruyenTrollServiceImpl implements ContentTruyenTrollService {
	
	@Autowired
	private ContentTruyenTrollDao contentTruyenTrollDao;

	@Override
	public void save(ContentTruyenTroll entity) {
		contentTruyenTrollDao.save(entity);
	}

	@Override
	public ContentTruyenTroll findById(Long id) {
		return contentTruyenTrollDao.findById(id);
	}

	@Override
	public List<ContentTruyenTroll> getAll() {
		return contentTruyenTrollDao.findAll();
	}

	@Override
	public ContentTruyenTroll findByProperty(String column, Object value) {
		List<ContentTruyenTroll> lst = contentTruyenTrollDao.findByProperty(column, value);
		return (lst.size()>0)?lst.get(0):null;
	}

	@Override
	public List<ContentTruyenTroll> getAllLst(String kwSearch, String sort, String sortBy,
			PagingInfo pInfo) {
		return contentTruyenTrollDao.getAllLst(kwSearch,sort,sortBy,pInfo);
	}

	@Override
	@Transactional
	public void delete(long id) {
		ContentTruyenTroll entity = findById(id);
		if(entity != null){
			contentTruyenTrollDao.delete(entity);
		}
	}

	@Override
	public List<ContentTruyenTroll> getLstByTruyen(TruyenTroll entity, String kwSearch,
			String sort, String sortBy, PagingInfo pInfo) {
		return contentTruyenTrollDao.getLstByTruyen(entity,kwSearch,sort,sortBy,pInfo);
	}


}
